<template>



  <div>



    <el-carousel  type="card" style="height: 40vh; margin-top:20px;">
      <el-carousel-item v-for="(item,index) in swiperList" :key="index" class="swiper-slide">
        <router-link :to="item.linkUrl">
          <img :src="item.imageUrl" alt="首页banner" >
        </router-link>

      </el-carousel-item>
    </el-carousel>
    <!-- 幻灯片 结束 -->



     <div id="aCoursesList">

      <!-- 网校课程 开始 -->

      <div>

        <section class="container">

          <header class="comm-title">

            <h2 class="tac">

              <span class="c-333">热门课程</span>

            </h2>

          </header>

          <div>

            <article class="comm-course-list">

              <ul class="of" id="bna">

                <li v-for="(item,index) in Courselist" :key="index">

                  <div class="cc-l-wrap">

                    <section class="course-img">
                      <router-link :to="/course/+item.id">
                      <img
                        v-if="isImg(item.cover)"
                        src="@/static/timg.jpg"

                        class="img-responsive "
                        style="width: 257.5px;height: 143.6px;"


                        :alt="item.title"

                      >
                      <img
                        v-else
                        :src="item.cover"
                        class="img-responsive "
                        style="width: 257.5px;height: 143.6px;"
                        :alt="item.title"
                      >

                      <div class="cc-mask">

                        <a :href="/course/+item.id" title="开始学习" class="comm-btn c-btn-1">开始学习</a>

                      </div>
                      </router-link>

                    </section>

                    <h3 class="hLh30 txtOf mt10">

                      <a :href="/course/+item.id" title="听力口语" class="course-title fsize18 c-333">{{item.title}}</a>

                    </h3>

                    <section class="mt10 hLh20 of">

                      <span class="fr jgTag bg-green" :style="{background:(item.price!=0?'#fff':'')}">

                        <i class="c-fff fsize12 f-fA" :style="{color:(item.price!=0?'red':''),fontSize:(item.price!=0?'18px':''),fontWeight:(item.price!=0?'bold':'')}" >{{item.price==0?"免 费":"￥"+item.price}}</i>

                      </span>

                      <span class="fl jgAttr c-ccc f-fA">

                        <i class="c-999 f-fA">{{item.viewCount}}浏览</i>

                        |

                        <i class="c-999 f-fA">{{item.buyCount}}销售</i>

                      </span>

                    </section>

                  </div>

                </li>






              </ul>
              <div class="clear"></div>
            </article>
            <section class="tac pt20">
              <a href="#" title="全部课程" class="comm-btn c-btn-2">全部课程</a>
            </section>
          </div>
        </section>
      </div>
      <!-- /网校课程 结束 -->
      <!-- 网校名师 开始 -->
      <div>

        <section class="container">

          <header class="comm-title">

            <h2 class="tac">

              <span class="c-333">名师大咖</span>

            </h2>

          </header>

          <div>

            <article class="i-teacher-list">

              <ul class="of">

                <li v-for="(item,index) in teacherlist" :key="index">
                  <section class="i-teach-wrap">
                    <div class="i-teach-pic">
                      <a :href="/teacher/+item.id" title="姚晨">
                        <img :alt="item.name" :src="item.avatar" style="width: 135px; height: 135px;">
                      </a>
                    </div>
                    <div class="mt10 hLh30 txtOf tac">
                      <a href="/teacher/1" title="姚晨" class="fsize18 c-666">{{item.name}}</a>
                    </div>
                    <div class="hLh30 txtOf tac">
                      <span class="fsize14 c-999">{{item.career}}</span>
                    </div>
                    <div class="mt15 i-q-txt">
                      <p
                        class="c-999 f-fA"

                      >
                      {{item.intro}}
                      </p>

                    </div>

                  </section>

                </li>



              </ul>

              <div class="clear"></div>

         </article>

            <section class="tac pt20">

              <a href="#" title="全部讲师" class="comm-btn c-btn-2">全部讲师</a>

            </section>

          </div>

        </section>

      </div>

      <!-- /网校名师 结束 -->
    </div>
  </div>

</template>
<script>
import {getBannerAll,indexfront} from '~/http'

export default {
  data () {
    return {
      swiperList:[],//轮播图
      Courselist:[],//课程
      teacherlist:[],//讲师

    }
  },
  mounted(){
    this.getAll()
  },
  methods:{
    getAll(){
      getBannerAll().then(res=>{
        this.swiperList = res.data.list
      })
      indexfront().then(res=>{
       this.teacherlist = res.data.teacher
        this.Courselist = res.data.Course
      })
    },
    isImg(text){

      if(text.includes("https"))return false
       return true
    }
  }
}
</script>
<style scoped>
.swiper-container{
    --swiper-theme-color: #ff6600;
    --swiper-pagination-color: #00ff33;/* 两种都可以 */
  }
.swiper-slide img{
  width: 60vw;
  height: 40vh;
}
.img-responsive{

}
</style>
